﻿using System;


namespace ExtensibleEventViewer.Console.Controls
{
	public partial class EventLogAdapterSettingsControl : DecoratedUserControl
	{
		public EventLogAdapterSettingsControl()
		{
			InitializeComponent();
		}

		public bool EnableRefresh
		{
			get
			{
				return cbEnableRefresh.Checked;
			}
			set
			{
				cbEnableRefresh.Checked = value;
			}
		}

		public bool UseDefaultRefreshInterval
		{
			get
			{
				return cbUseDefaultRefreshInterval.Checked;
			}
			set
			{
				cbUseDefaultRefreshInterval.Checked = value;
			}
		}

		public TimeSpan RefreshInterval
		{
			get
			{
				return timePeriodControl.TimePeriod;
			}
			set
			{
				timePeriodControl.TimePeriod = value;
			}
		}

		private void UseDefaultRefreshIntervalCheckedChanged(object sender, EventArgs e)
		{
			timePeriodControl.Enabled = !cbUseDefaultRefreshInterval.Checked;
		}

		private void EnableRefreshCheckedChanged(object sender, EventArgs e)
		{
			cbUseDefaultRefreshInterval.Enabled = cbEnableRefresh.Checked;

			if (cbEnableRefresh.Checked)
			{
				UseDefaultRefreshIntervalCheckedChanged(sender, e);
			}
			else
			{
				timePeriodControl.Enabled = false;
			}
		}
	}
}
